home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / dsm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  29.7 KB  |  997 lines

  1. /*      DSM.H
  2.  *
  3.  * Digital Sound Mixer
  4.  *
  5.  * $Id: dsm.h,v 1.7 1997/01/16 18:41:59 pekangas Exp $
  6.  *
  7.  * Copyright 1996,1997 Housemarque Inc.
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16. #ifndef __DSM_H
  17. #define __DSM_H
  18.  
  19.  
  20. #define VOLLEVELS 33
  21. #define VOLSHIFT 1
  22.  
  23. /* Magic sample handle for streams: */
  24. #define DSM_SMP_STREAM MAXSAMPLES
  25.  
  26.  
  27. #include "sdevice.h"
  28.  
  29.  
  30. /****************************************************************************\
  31. *       enum dsmMixMode
  32. *       ---------------
  33. * Description:  Available DSM mixing modes
  34. \****************************************************************************/
  35.  
  36. enum dsmMixMode
  37. {
  38.     dsmMixMono = 1,                     /* mono mixing */
  39.     dsmMixStereo = 2                    /* stereo mixing */
  40. };
  41.  
  42.  
  43.  
  44.  
  45. /****************************************************************************\
  46. *       enum dsmChanStatus
  47. *       ------------------
  48. * Description:  DSM channel sound playing status
  49. \****************************************************************************/
  50.  
  51. enum dsmChanStatus
  52. {
  53.     dsmChanStopped = 0,                 /* playing is stopped */
  54.     dsmChanEnd,                         /* playing has ended (not forced
  55.                                            stopped */
  56.     dsmChanPlaying,                     /* playing, not released */
  57.     dsmChanReleased                     /* playing, note has been released */
  58. };
  59.  
  60.  
  61.  
  62.  
  63. /****************************************************************************\
  64. *       enum dsmPlayDir
  65. *       ---------------
  66. * Description:  Playing direction in bidirectional loops
  67. \****************************************************************************/
  68.  
  69. enum dsmPlayDir
  70. {
  71.     dsmPlayBackwards = -1,              /* playing backwards */
  72.     dsmPlayForward = 1                  /* playing forward */
  73. };
  74.  
  75.  
  76.  
  77.  
  78. /****************************************************************************\
  79. *       struct dsmChannel
  80. *       -----------------
  81. * Description:  DSM channel data
  82. \****************************************************************************/
  83.  
  84. typedef struct
  85. {
  86.     uchar       *sample;                /* sample data pointer */
  87.     int         sampleType;             /* sample type, see enum
  88.                                            sdSampleType */
  89.     int         samplePos;              /* sample position in memory */
  90.     unsigned    sampleLength;           /* sample length */
  91.     int         loopMode;               /* sample looping mode, see enum
  92.                                            sdLoopMode */
  93.     unsigned    loop1Start;             /* first loop start */
  94.     unsigned    loop1End;               /* first loop end */
  95.     int         loop1Type;              /* first loop type, see enum
  96.                                            sdLoopType */
  97.     unsigned    loop2Start;             /* second loop start */
  98.     unsigned    loop2End;               /* second loop end */
  99.     int         loop2Type;              /* second loop type, see enum
  100.                                            sdLoopType */
  101.  
  102.     unsigned    playPos;                /* playing position whole part */
  103.     unsigned    playPosLow;             /* playing position fractional part
  104.                                            (only lower 16 bits used) */
  105.     unsigned    streamWritePos;         /* stream write position */
  106.     ulong       rate;                   /* playing rate in Hz */
  107.     int         direction;              /* playing direction in bidirectional
  108.                                            loops - 1 is forward, -1 back */
  109.     unsigned    sampleHandle;           /* sample handle */
  110.     unsigned    sampleChanged;          /* 1 if sample has been changed
  111.                                            but values not yet set in
  112.                                            channel struct */
  113.     int         panning;                /* panning information */
  114.     unsigned    volume;                 /* playing volume (0-64) */
  115.     int         muted;                  /* 1 if channel muted, 0 if not */
  116.     int         status;                 /* channel status, see enum dsm
  117.                                            dsmChanStatus */
  118.     int         loopNum;                /* currently played sample loop */
  119.     void (CALLING *LoopCallback)(unsigned channel);     /* sample loop
  120.                                                            callback */
  121. } dsmChannel;
  122.  
  123.  
  124.  
  125.  
  126. /****************************************************************************\
  127. *       struct dsmSample
  128. *       ----------------
  129. * Description:  DSM internal sample structure
  130. \****************************************************************************/
  131.  
  132. typedef struct
  133. {
  134.     uchar       *sample;                /* sample data pointer */
  135.     int         sampleType;             /* sample type, see enum
  136.                                            sdSampleType */
  137.     int         samplePos;              /* sample position in memory */
  138.     unsigned    sampleLength;           /* sample length */
  139.     int         loopMode;               /* sample looping mode, see enum
  140.                                            sdLoopMode */
  141.     unsigned    loop1Start;             /* first loop start */
  142.     unsigned    loop1End;               /* first loop end */
  143.     int         loop1Type;              /* first loop type, see enum
  144.                                            sdLoopType */
  145.     unsigned    loop2Start;             /* second loop start */
  146.     unsigned    loop2End;               /* second loop end */
  147.     int         loop2Type;              /* second loop type, see enum
  148.                                            sdLoopType */
  149.     int         inUse;                  /* 1 if sample is in use, 0 if not
  150.                                            (removed using dsmRemoveSample) */
  151.     int         copied;                 /* 1 if a copied sample (should be
  152.                                            deallocated), 0 if not */
  153. } dsmSample;
  154.  
  155.  
  156.  
  157. #ifdef __cplusplus
  158. extern "C" {
  159. #endif
  160.  
  161.  
  162.  
  163.  
  164. extern unsigned * GLOBALVAR dsmMixBuffer;  /* DSM mixing buffer. dsmPlay()
  165.                                            writes the mixed data here. Post-
  166.                                            processing is usually necessary. */
  167. extern unsigned GLOBALVAR dsmMixBufferSize;      /* DSM mixing buffer size */
  168.  
  169. /* The following global variables are used internally by different DSM
  170.    functions and should not be accessed by other modules: */
  171.  
  172. extern unsigned GLOBALVAR dsmMixRate;   /* mixing rate in Hz */
  173. extern unsigned GLOBALVAR dsmMode;      /* output mode (see enum
  174.                                            dsmMixMode) */
  175. #ifdef __16__
  176. extern unsigned GLOBALVAR dsmVolTableSeg;   /* volume table segment */
  177. #endif
  178. extern unsigned GLOBALVAR *dsmVolumeTable;  /* pointer to volume table */
  179.  
  180. extern dsmChannel * GLOBALVAR dsmChannels;  /* pointer to channel datas */
  181. extern dsmSample * GLOBALVAR dsmSamples;    /* sample structures */
  182. extern unsigned GLOBALVAR dsmOutputBits;    /* output bit width */
  183.  
  184.  
  185.  
  186.  
  187. /****************************************************************************\
  188. *
  189. * Function:     int dsmInit(unsigned mixRate, unsigned mode,
  190. *                   unsigned outputBits);
  191. *
  192. * Description:  Initializes Digital Sound Mixer
  193. *
  194. * Input:        unsigned mixRate        mixing rate in Hz
  195. *               unsigned mode           mixing mode (see enum dsmMixMode)
  196. *               unsigned outputBits     output bit width (if less than
  197. *                                       16, output values are divided
  198. *                                       accordingly - mixing buffer is
  199. *                                       always a sequence of unsigned ints)
  200. *
  201. * Returns:      MIDAS error code
  202. *
  203. \****************************************************************************/
  204.  
  205. int CALLING dsmInit(unsigned mixRate, unsigned mode, unsigned amplitude);
  206.  
  207.  
  208.  
  209.  
  210. /****************************************************************************\
  211. *
  212. * Function:     int dsmClose(void)
  213. *
  214. * Description:  Uninitializes Digital Sound Mixer
  215. *
  216. * Returns:      MIDAS error code
  217. *
  218. \****************************************************************************/
  219.  
  220. int CALLING dsmClose(void);
  221.  
  222.  
  223.  
  224.  
  225. /****************************************************************************\
  226. *
  227. * Function:     int dsmGetMixRate(unsigned *mixRate)
  228. *
  229. * Description:  Reads the actual mixing rate
  230. *
  231. * Input:        unsigned *mixRate       pointer to mixing rate variable
  232. *
  233. * Returns:      MIDAS error code.
  234. *               Mixing rate, in Hz, is stored in *mixRate
  235. *
  236. \****************************************************************************/
  237.  
  238. int CALLING dsmGetMixRate(unsigned *mixRate);
  239.  
  240.  
  241.  
  242.  
  243. /****************************************************************************\
  244. *
  245. * Function:     int dsmOpenChannels(unsigned channels);
  246. *
  247. * Description:  Opens channels for output
  248. *
  249. * Input:        unsigned channels       number of channels to open
  250. *
  251. * Returns:      MIDAS error code
  252. *
  253. \****************************************************************************/
  254.  
  255. int CALLING dsmOpenChannels(unsigned channels);
  256.  
  257.  
  258.  
  259.  
  260. /****************************************************************************\
  261. *
  262. * Function:     int dsmCalcVolTable(unsigned amplification)
  263. *
  264. * Description:  Calculates a new volume table
  265. *
  266. * Input:        unsigned amplification  Amplification level. 64 - normal
  267. *                                       (100%), 32 = 50%, 128 = 200% etc.
  268. *
  269. * Returns:      MIDAS error code
  270. *
  271. \****************************************************************************/
  272.  
  273. int CALLING dsmCalcVolTable(unsigned amplification);
  274.  
  275.  
  276.  
  277.  
  278. /****************************************************************************\
  279. *
  280. * Function:     int dsmCloseChannels(void)
  281. *
  282. * Description:  Closes open output channels
  283. *
  284. * Returns:      MIDAS error code
  285. *
  286. \****************************************************************************/
  287.  
  288. int CALLING dsmCloseChannels(void);
  289.  
  290.  
  291.  
  292.  
  293. /****************************************************************************\
  294. *
  295. * Function:     int dsmClearChannels(void)
  296. *
  297. * Description:  Clears open channels (removes all sounds)
  298. *
  299. * Returns:      MIDAS error code
  300. *
  301. \****************************************************************************/
  302.  
  303. int CALLING dsmClearChannels(void);
  304.  
  305.  
  306.  
  307.  
  308. /****************************************************************************\
  309. *
  310. * Function:     int dsmMute(int mute)
  311. *
  312. * Description:  Mutes all channels
  313. *
  314. * Input:        int mute                1 = mute, 0 = un-mute
  315. *
  316. * Returns:      MIDAS error code
  317. *
  318. \****************************************************************************/
  319.  
  320. int CALLING dsmMute(int mute);
  321.  
  322.  
  323.  
  324.  
  325. /****************************************************************************\
  326. *
  327. * Function:     int dsmPause(int pause)
  328. *
  329. * Description:  Pauses or resumes playing
  330. *
  331. * Input:        int pause               1 = pause, 0 = resume
  332. *
  333. * Returns:      MIDAS error code
  334. *
  335. \****************************************************************************/
  336.  
  337. int CALLING dsmPause(int pause);
  338.  
  339.  
  340.  
  341.  
  342. /****************************************************************************\
  343. *
  344. * Function:     int dsmSetMasterVolume(unsigned masterVolume)
  345. *
  346. * Description:  Sets the master volume
  347. *
  348. * Input:        unsigned masterVolume   master volume (0 - 64)
  349. *
  350. * Returns:      MIDAS error code
  351. *
  352. \****************************************************************************/
  353.  
  354. int CALLING dsmSetMasterVolume(unsigned masterVolume);
  355.  
  356.  
  357.  
  358.  
  359. /****************************************************************************\
  360. *
  361. * Function:     int dsmGetMasterVolume(unsigned *masterVolume)
  362. *
  363. * Description:  Reads the master volume
  364. *
  365. * Input:        unsigned *masterVolume  pointer to master volume
  366. *
  367. * Returns:      MIDAS error code. Master volume is written to *masterVolume.
  368. *
  369. \****************************************************************************/
  370.  
  371. int CALLING dsmGetMasterVolume(unsigned *masterVolume);
  372.  
  373.  
  374.  
  375.  
  376. /****************************************************************************\
  377. *
  378. * Function:     int dsmSetAmplification(unsigned amplification)
  379. *
  380. * Description:  Sets amplification level and calculates new volume table.
  381. *
  382. * Input:        unsigned amplification  amplification level, 64 = normal
  383. *
  384. * Returns:      MIDAS error code
  385. *
  386. \****************************************************************************/
  387.  
  388. int CALLING dsmSetAmplification(unsigned amplification);
  389.  
  390.  
  391.  
  392.  
  393. /****************************************************************************\
  394. *
  395. * Function:     int dsmGetAmplification(unsigned *amplification)
  396. *
  397. * Description:  Reads the amplification level
  398. *
  399. * Input:        unsigned *amplification   pointer to amplification level
  400. *
  401. * Returns:      MIDAS error code. Amplification level is written to
  402. *               *amplification.
  403. *
  404. \****************************************************************************/
  405.  
  406. int CALLING dsmGetAmplification(unsigned *amplification);
  407.  
  408.  
  409.  
  410.  
  411. /****************************************************************************\
  412. *
  413. * Function:     int dsmPlaySound(unsigned channel, ulong rate)
  414. *
  415. * Description:  Starts playing a sound
  416. *
  417. * Input:        unsigned channel        channel number
  418. *               ulong rate              playing rate in Hz
  419. *
  420. * Returns:      MIDAS error code
  421. *
  422. \****************************************************************************/
  423.  
  424. int CALLING dsmPlaySound(unsigned channel, ulong rate);
  425.  
  426.  
  427.  
  428.  
  429. /****************************************************************************\
  430. *
  431. * Function:     int dsmReleaseSound(unsigned channel)
  432. *
  433. * Description:  Releases the current sound from the channel. If sdLoop1Rel or
  434. *               sdLoop2 looping modes are used, playing will be continued from
  435. *               the release part of the current sample (data after the end
  436. *               of the first loop) after the end of the first loop is reached
  437. *               next time, otherwise the sound will be stopped.
  438. *
  439. * Input:        unsigned channel        channel number
  440. *
  441. * Returns:      MIDAS error code
  442. *
  443. \****************************************************************************/
  444.  
  445. int CALLING dsmReleaseSound(unsigned channel);
  446.  
  447.  
  448.  
  449.  
  450. /****************************************************************************\
  451. *
  452. * Function:     int dsmStopSound(unsigned channel)
  453. *
  454. * Description:  Stops playing a sound
  455. *
  456. * Input:        unsigned channel        channel number
  457. *
  458. * Returns:      MIDAS error code
  459. *
  460. \****************************************************************************/
  461.  
  462. int CALLING dsmStopSound(unsigned channel);
  463.  
  464.  
  465.  
  466.  
  467. /****************************************************************************\
  468. *
  469. * Function:     int dsmSetRate(unsigned channel, ulong rate)
  470. *
  471. * Description:  Sets the playing rate
  472. *
  473. * Input:        unsigned channel        channel number
  474. *               ulong rate              playing rate in Hz
  475. *
  476. * Returns:      MIDAS error code
  477. *
  478. \****************************************************************************/
  479.  
  480. int CALLING dsmSetRate(unsigned channel, ulong rate);
  481.  
  482.  
  483.  
  484.  
  485. /****************************************************************************\
  486. *
  487. * Function:     int dsmGetRate(unsigned channel, ulong *rate)
  488. *
  489. * Description:  Reads the playing rate on a channel
  490. *
  491. * Input:        unsigned channel        channel number
  492. *               ulong *rate             pointer to playing rate
  493. *
  494. * Returns:      MIDAS error code. Playing rate is written to *rate, 0 if
  495. *               no sound is being played.
  496. *
  497. \****************************************************************************/
  498.  
  499. int CALLING dsmGetRate(unsigned channel, ulong *rate);
  500.  
  501.  
  502.  
  503.  
  504. /****************************************************************************\
  505. *
  506. * Function:     int dsmSetVolume(unsigned channel, unsigned volume)
  507. *
  508. * Description:  Sets the playing volume
  509. *
  510. * Input:        unsigned channel        channel number
  511. *               unsigned volume         playing volume (0-64)
  512. *
  513. * Returns:      MIDAS error code
  514. *
  515. \****************************************************************************/
  516.  
  517. int CALLING dsmSetVolume(unsigned channel, unsigned volume);
  518.  
  519.  
  520.  
  521.  
  522. /****************************************************************************\
  523. *
  524. * Function:     int dsmGetVolume(unsigned channel, unsigned *volume)
  525. *
  526. * Description:  Reads the playing volume
  527. *
  528. * Input:        unsigned channel        channel number
  529. *               unsigned *volume        pointer to volume
  530. *
  531. * Returns:      MIDAS error code. Playing volume is written to *volume.
  532. *
  533. \****************************************************************************/
  534.  
  535. int CALLING dsmGetVolume(unsigned channe, unsigned *volume);
  536.  
  537.  
  538.  
  539.  
  540. /****************************************************************************\
  541. *
  542. * Function:     int dsmSetSample(unsigned channel, unsigned smpHandle)
  543. *
  544. * Description:  Sets the sample number on a channel
  545. *
  546. * Input:        unsigned channel        channel number
  547. *               unsigned smpHandle      sample handle returned by
  548. *                                       dsmAddSample()
  549. *
  550. * Returns:      MIDAS error code
  551. *
  552. \****************************************************************************/
  553.  
  554. int CALLING dsmSetSample(unsigned channel, unsigned smpHandle);
  555.  
  556.  
  557.  
  558.  
  559. /****************************************************************************\
  560. *
  561. * Function:     int dsmGetSample(unsigned channel, unsigned *smpHandle)
  562. *
  563. * Description:  Reads current sample handle
  564. *
  565. * Input:        unsigned channel        channel number
  566. *               unsigned *smpHandle     pointer to sample handle
  567. *
  568. * Returns:      MIDAS error code. Sample handle is written to *smpHandle;
  569. *
  570. \****************************************************************************/
  571.  
  572. int CALLING dsmGetSample(unsigned channel, unsigned *smpHandle);
  573.  
  574.  
  575.  
  576.  
  577. /****************************************************************************\
  578. *
  579. * Function:     int dsmChangeSample(unsigned channel)
  580. *
  581. * Description:  Changes the sample used in a channel to the one specified
  582. *               by the channel's sample handle. Used only internally by
  583. *               other DSM functions, does no error checking.
  584. *
  585. * Input:        unsigned channel        channel number
  586. *
  587. * Returns:      MIDAS error code (does not fail)
  588. *
  589. \****************************************************************************/
  590.  
  591. int CALLING dsmChangeSample(unsigned channel);
  592.  
  593.  
  594.  
  595.  
  596. /****************************************************************************\
  597. *
  598. * Function:     int dsmSetPosition(unsigned channel, unsigned position)
  599. *
  600. * Description:  Sets the playing position from the beginning of the sample
  601. *
  602. * Input:        unsigned channel        channel number
  603. *               unsigned position       new playing position
  604. *
  605. * Returns:      MIDAS error code
  606. *
  607. \****************************************************************************/
  608.  
  609. int CALLING dsmSetPosition(unsigned channel, unsigned position);
  610.  
  611.  
  612.  
  613.  
  614. /****************************************************************************\
  615. *
  616. * Function:     int dsmGetPosition(unsigned channel, unsigned *position)
  617. *
  618. * Description:  Reads the current playing position
  619. *
  620. * Input:        unsigned channel        channel number
  621. *               unsigned *position      pointer to playing position
  622. *
  623. * Returns:      MIDAS error code. Playing position is written to *position.
  624. *
  625. \****************************************************************************/
  626.  
  627. int CALLING dsmGetPosition(unsigned channel, unsigned *position);
  628.  
  629.  
  630.  
  631.  
  632. /****************************************************************************\
  633. *
  634. * Function:     int dsmGetDirection(unsigned channel, int *direction)
  635. *
  636. * Description:  Reads current playing direction
  637. *
  638. * Input:        unsigned channel        channel number
  639. *               int *direction          pointer to playing direction. 1 is
  640. *                                       forward, -1 backwards
  641. *
  642. * Returns:      MIDAS error code. Playing direction is written to *direction.
  643. *
  644. \****************************************************************************/
  645.  
  646. int CALLING dsmGetDirection(unsigned channel, int *direction);
  647.  
  648.  
  649.  
  650.  
  651. /****************************************************************************\
  652. *
  653. * Function:     int dsmSetPanning(unsigned channel, int panning)
  654. *
  655. * Description:  Sets the panning position of a channel
  656. *
  657. * Input:        unsigned channel        channel number
  658. *               int panning             panning position (see enum sdPanning)
  659. *
  660. * Returns:      MIDAS error code
  661. *
  662. \****************************************************************************/
  663.  
  664. int CALLING dsmSetPanning(unsigned channel, int panning);
  665.  
  666.  
  667.  
  668.  
  669. /****************************************************************************\
  670. *
  671. * Function:     int dsmGetPanning(unsigned channel, int *panning)
  672. *
  673. * Description:  Reads the panning position of a channel
  674. *
  675. * Input:        unsigned channel        channel number
  676. *               int *panning            pointer to panning position
  677. *
  678. * Returns:      MIDAS error code. Panning position is written to *panning.
  679. *
  680. \****************************************************************************/
  681.  
  682. int CALLING dsmGetPanning(unsigned channel, int *panning);
  683.  
  684.  
  685.  
  686.  
  687. /****************************************************************************\
  688. *
  689. * Function:     int dsmMuteChannel(unsigned channel, int mute)
  690. *
  691. * Description:  Mutes/un-mutes a channel
  692. *
  693. * Input:        unsigned channel        channel number
  694. *               int mute                muting status - 1 = mute, 0 = un-mute
  695. *
  696. * Returns:      MIDAS error code
  697. *
  698. \****************************************************************************/
  699.  
  700. int CALLING dsmMuteChannel(unsigned channel, int mute);
  701.  
  702.  
  703.  
  704.  
  705. /****************************************************************************\
  706. *
  707. * Function:     int dsmAddSample(sdSample *sample, int copySample,
  708. *                   unsigned *smpHandle);
  709. *
  710. * Description:  Adds a new sample to the DSM sample list and prepares it for
  711. *               DSM use
  712. *
  713. * Input:        sdSample *sample        pointer to sample information
  714. *                                           structure
  715. *               int copySample          copy sample data to a new place in
  716. *                                       memory? 1 = yes, 0 = no
  717. *               unsigned *smpHandle     pointer to sample handle
  718. *
  719. * Returns:      MIDAS error code. Sample handle for the new sample is written
  720. *               to *smpHandle
  721. *
  722. * Notes:        If copySample = 1, sample data must not be in EMS memory
  723. *
  724. \****************************************************************************/
  725.  
  726. int CALLING dsmAddSample(sdSample *sample, int copySample, unsigned *smpHandle);
  727.  
  728.  
  729.  
  730.  
  731. /****************************************************************************\
  732. *
  733. * Function:     int dsmRemoveSample(unsigned smpHandle)
  734. *
  735. * Description:  Removes a sample from the sample list and deallocates it if
  736. *               necessary.
  737. *
  738. * Input:        unsigned smpHandle      sample handle returned by
  739. *                                       dsmAddSample()
  740. *
  741. * Returns:      MIDAS error code
  742. *
  743. \****************************************************************************/
  744.  
  745. int CALLING dsmRemoveSample(unsigned smpHandle);
  746.  
  747.  
  748.  
  749.  
  750. /****************************************************************************\
  751. *
  752. * Function:     int dsmMixData(unsigned numElems)
  753. *
  754. * Description:  Mixes data to dsmMixBuffer.
  755. *
  756. * Input:        unsigned numElems       number of buffer elements to be mixed.
  757. *                                       In mono modes an "element" is an
  758. *                                       unsigned integer, and in stereo
  759. *                                       two.
  760. *
  761. * Returns:      MIDAS error code. Mixed data is written to *dsmMixBuffer.
  762. *
  763. \****************************************************************************/
  764.  
  765. int CALLING dsmMixData(unsigned numElems);
  766.  
  767.  
  768.  
  769.  
  770. /****************************************************************************\
  771. *
  772. * Function:     int dsmMix(unsigned channel, void *mixRoutine,
  773. *                   unsigned volume, unsigned numElems);
  774. *
  775. * Description:  Mixes data for one channel. Used internally by dsmMixData().
  776. *
  777. * Input:        unsigned channel        channel number
  778. *               void *mixRoutine        pointer to low-level mixing routine
  779. *               unsigned volume         actual playing volume (volume in
  780. *                                       channel structure is ignored)
  781. *               unsigned numElems       number of elements to mix (see
  782. *                                       dsmMixData())
  783. *
  784. * Returns:      MIDAS error code
  785. *
  786. \****************************************************************************/
  787.  
  788. int CALLING dsmMix(unsigned channel, void *mixRoutine, unsigned volume,
  789.     unsigned numElems);
  790.  
  791.  
  792.  
  793.  
  794. /****************************************************************************\
  795. *
  796. * Function:     int dsmClearBuffer(unsigned numElems)
  797. *
  798. * Description:  Clears the mixing buffer. Used only by dsmMixData().
  799. *
  800. * Input:        unsigned numElems       number of elements to clear
  801. *
  802. * Returns:      MIDAS error code.
  803. *
  804. \****************************************************************************/
  805.  
  806. int CALLING dsmClearBuffer(unsigned numElems);
  807.  
  808.  
  809.  
  810.  
  811. #ifdef SUPPORTSTREAMS
  812.  
  813.  
  814. /****************************************************************************\
  815. *
  816. * Function:     int dsmStartStream(unsigned channel, uchar *buffer,
  817. *                   unsigned bufferLength, int sampleType);
  818. *
  819. * Description:  Starts playing a digital audio stream on a channel
  820. *
  821. * Input:        unsigned channel        channel number
  822. *               uchar *buffer           pointer to stream buffer
  823. *               unsigned bufferLength   buffer length in bytes
  824. *               int sampleType          stream sample type
  825. *               ulong rate              stream playing rate (in Hz)
  826. *
  827. * Returns:      MIDAS error code
  828. *
  829. \****************************************************************************/
  830.  
  831. int CALLING dsmStartStream(unsigned channel, uchar *buffer, unsigned
  832.     bufferLength, int sampleType, ulong rate);
  833.  
  834.  
  835.  
  836.  
  837. /****************************************************************************\
  838. *
  839. * Function:     int dsmStopStream(unsigned channel);
  840. *
  841. * Description:  Stops playing digital audio stream on a channel
  842. *
  843. * Input:        unsigned channel        channel number
  844. *
  845. * Returns:      MIDAS error code
  846. *
  847. \****************************************************************************/
  848.  
  849. int CALLING dsmStopStream(unsigned channel);
  850.  
  851.  
  852.  
  853.  
  854. /****************************************************************************\
  855. *
  856. * Function:     int dsmSetLoopCallback(unsigned channel,
  857. *                   void (CALLING *callback)(unsigned channel));
  858. *
  859. * Description:  Sets sample looping callback to a channel
  860. *
  861. * Input:        unsigned channel        channel number
  862. *               [..] *callback          pointer to callback function, NULL to
  863. *                                       disable callback
  864. *
  865. * Returns:      MIDAS error code
  866. *
  867. \****************************************************************************/
  868.  
  869. int CALLING dsmSetLoopCallback(unsigned channel,
  870.     void (CALLING *callback)(unsigned channel));
  871.  
  872.  
  873.  
  874.  
  875. /****************************************************************************\
  876. *
  877. * Function:     int dsmSetStreamWritePosition(unsigned channel,
  878. *                   unsigned position)
  879. *
  880. * Description:  Sets the stream write position on a channel
  881. *
  882. * Input:        unsigned channel        channel number
  883. *               unsigned position       new stream write position
  884. *
  885. * Returns:      MIDAS error code
  886. *
  887. \****************************************************************************/
  888.  
  889. int CALLING dsmSetStreamWritePosition(unsigned channel, unsigned position);
  890.  
  891.  
  892.  
  893. #endif /* #ifdef SUPPORTSTREAMS */
  894.  
  895.  
  896. /* Prototypes for the actual mixing routines: */
  897. void CALLING dsmMix8bitMonoMono(void);      /* 8-bit Mono => Mono */
  898. void CALLING dsmMix8bitMonoStereo(void);    /* 8-bit Mono => Stereo */
  899. void CALLING dsmMix8bitStereoMono(void);    /* 8-bit Stereo => Mono */
  900. void CALLING dsmMix8bitStereoStereo(void);  /* 8-bit Stereo => Stereo */
  901. void CALLING dsmMix16bitMonoMono(void);     /* 16-bit Mono => Mono */
  902. void CALLING dsmMix16bitMonoStereo(void);   /* 16-bit Mono => Stereo */
  903. void CALLING dsmMix16bitStereoMono(void);   /* 16-bit Stereo => Mono */
  904. void CALLING dsmMix16bitStereoStereo(void); /* 16-bit Stereo => Stereo */
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912. #ifdef __cplusplus
  913. }
  914. #endif
  915.  
  916.  
  917.  
  918. /****************************************************************************\
  919. *       enum dsmFunctIDs
  920. *       ----------------
  921. * Description:  ID numbers for DSM functions
  922. \****************************************************************************/
  923.  
  924. enum dsmFunctIDs
  925. {
  926.     ID_dsmInit = ID_dsm,
  927.     ID_dsmClose,
  928.     ID_dsmGetMixRate,
  929.     ID_dsmOpenChannels,
  930.     ID_dsmCalcVolTable,
  931.     ID_dsmCloseChannels,
  932.     ID_dsmClearChannels,
  933.     ID_dsmMute,
  934.     ID_dsmPause,
  935.     ID_dsmSetMasterVolume,
  936.     ID_dsmGetMasterVolume,
  937.     ID_dsmSetAmplification,
  938.     ID_dsmGetAmplification,
  939.     ID_dsmPlaySound,
  940.     ID_dsmReleaseSound,
  941.     ID_dsmStopSound,
  942.     ID_dsmSetRate,
  943.     ID_dsmGetRate,
  944.     ID_dsmSetVolume,
  945.     ID_dsmGetVolume,
  946.     ID_dsmSetSample,
  947.     ID_dsmGetSample,
  948.     ID_dsmChangeSample,
  949.     ID_dsmSetPosition,
  950.     ID_dsmGetPosition,
  951.     ID_dsmGetDirection,
  952.     ID_dsmSetPanning,
  953.     ID_dsmGetPanning,
  954.     ID_dsmMuteChannel,
  955.     ID_dsmAddSample,
  956.     ID_dsmRemoveSample,
  957.     ID_dsmMixData,
  958.     ID_dsmMix,
  959.     ID_dsmMixMoNormal,
  960.     ID_dsmMixStNormal,
  961.     ID_dsmClearBuffer,
  962.     ID_dsmStartStream,
  963.     ID_dsmStopStream,
  964.     ID_dsmSetLoopCallback,
  965.     ID_dsmSetStreamWritePosition
  966. };
  967.  
  968.  
  969.  
  970. #endif
  971.  
  972.  
  973. /*
  974.  * $Log: dsm.h,v $
  975.  * Revision 1.7  1997/01/16 18:41:59  pekangas
  976.  * Changed copyright messages to Housemarque
  977.  *
  978.  * Revision 1.6  1997/01/16 18:19:10  pekangas
  979.  * Added support for setting the stream write position.
  980.  * Stream data is no longer played past the write position
  981.  *
  982.  * Revision 1.5  1996/07/13 18:13:25  pekangas
  983.  * Fixed to compile with Visual C
  984.  *
  985.  * Revision 1.4  1996/06/26 19:15:03  pekangas
  986.  * Added sample loop callbacks
  987.  *
  988.  * Revision 1.3  1996/05/28 20:29:56  pekangas
  989.  * Changed mixing routine prototypes and added new ones
  990.  *
  991.  * Revision 1.2  1996/05/26 20:55:20  pekangas
  992.  * Added dsmStartStream and dsmStopStream
  993.  *
  994.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  995.  * Initial revision
  996.  *
  997. */